package com.example.controller;

import com.example.index.User;
import com.example.service.UserService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * com.example.controller.UserController
 *
 * @author ZRS
 * @version V1.0
 * @since 2025/11/1 11:15
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    UserService userService;

    @PostMapping("/save")
    public User save(@RequestBody @Validated User user) {
        return userService.saveByTemplate(user);
    }

    @PostMapping("/detail/{id}")
    public User detail(@PathVariable("id") Integer id) {
        return userService.getById(id).get();
    }
}
